package org.bits.ui.model;

import java.util.Arrays;

import org.bits.common.model.ItemTableModel;
import org.bits.data.Issue;
import org.bits.data.IssueState;

public class IssuesTableModel extends ItemTableModel<Issue>
{
    public static final String[] HEADINGS;
    public static final Class<?>[] COLUMN_CLASSES;

    static
    {
        HEADINGS = new String[] { "Number", "State", "Title" };
        COLUMN_CLASSES = new Class<?>[] { Integer.class, IssueState.class,
            String.class };
    }

    public IssuesTableModel()
    {
        setColumnNames( Arrays.asList( HEADINGS ) );
        setColumnClasses( Arrays.asList( COLUMN_CLASSES ) );
    }

    @Override
    public Object getValueAtColumn( Issue issue, int col )
    {
        switch( col )
        {
            case 0:
                return issue.number;

            case 1:
                return issue.state;

            case 2:
                return issue.title;
        }

        throw new IllegalArgumentException( "The column " + col +
            " is invalid." );
    }
}
